package com.boot.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfig {
    public static final String token = "RabbitmqConfig";
    /**
     * @return
     * 创建新用户列队
     */
    @Bean
    public Queue wxCreateQueue() {
        return new Queue(token);
    }


    /**
     * Fanout 就是我们熟悉的广播模式或者订阅模式，给Fanout交换机发送消息，绑定了这个交换机的所有队列都收到这个消息。
     * @return
     */
    @Bean
    FanoutExchange fanoutExchange() {
        return new FanoutExchange("tokenChange");
    }


    @Bean
    Binding bindingExchangeA(Queue wxCreateQueue, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(wxCreateQueue).to(fanoutExchange);
    }

}
